<?php
class About extends Model {
	public function getAbout($field) {
		$result = $this->dbo->query("SELECT $field FROM company WHERE id=1");
		return $result->row;
	}
	public function updateAboutus($aboutus) {
		return $this->dbo->query("UPDATE company SET aboutus = '".$aboutus."' WHERE id=1");
	}
	public function updateCompany($company) {
		return $this->dbo->query("UPDATE company SET company = '".$company."' WHERE id=1");
	}
	public function updateSpread($spread) {
		return $this->dbo->query("UPDATE company SET spread = '".$spread."' WHERE id=1");
	}
	public function updateContact($contact) {
		return $this->dbo->query("UPDATE company SET contact = '".$contact."' WHERE id=1");
	}
	public function updatePartnership($partnership) {
		return $this->dbo->query("UPDATE company SET partnership = '".$partnership."' WHERE id=1");
	}
	public function addFeedback($data) {
		return $this->dbo->insertTableRow('feedback',$data);
	}
	public function addMessage($data) {
		return $this->dbo->insertTableRow('message',$data);
	}
	public function getMessageList($offset,$limit) {
		$result = $this->dbo->query("SELECT * FROM message LIMIT $offset,$limit");
		return $result->rows;
	}
	public function countMsgs() {
		$result = $this->dbo->query("SELECT count(*) as total FROM message");
		return $result->row['total'];
	}
	public function delMsgById($msg_id) {
		return $this->dbo->query("DELETE FROM message WHERE id='".$msg_id."'");
	}
	public function getFeedbackList($offset,$limit) {
		$result = $this->dbo->query("SELECT * FROM feedback LIMIT $offset,$limit");
		return $result->rows;
	}
	public function countFeedbacks() {
		$result = $this->dbo->query("SELECT count(*) as total FROM feedback");
		return $result->row['total'];
	}
	public function delFeedbackById($feedback_id) {
		return $this->dbo->query("DELETE FROM feedback WHERE id='".$feedback_id."'");
	}
	public function getFeedbackDetail($feedback_id) {
		$result = $this->dbo->query("SELECT * FROM feedback WHERE id = '".$feedback_id."'");
		return $result->row;
	}
	public function getMsgDetail($msg_id) {
		$result = $this->dbo->query("SELECT * FROM message WHERE id = '".$msg_id."'");
		return $result->row;
	}
}